

import Common from './common';

import {getAppPageConfig} from '../../../../hrpub/common/utils/utils';

export default class MainAction extends Common {
    constructor(comp) {
        super();
        this.comp = comp;
        if(comp.props.use){
            comp.props.use.editTable('entryList');
            comp.props.use.editTable('dimissionList');
            comp.props.use.editTable('regList');
            comp.props.use.search('regQuery');
            comp.props.use.search('dimissionQuery');
            comp.props.use.search('entryQuery');
        }
    }

    appConfig = getAppPageConfig();

    didMount = () => {
        this.getTemplate();
        this.getCurrentLanguage();
    }

    processTemplate = (res) => {
        ['dimissionList', 'entryList', 'regList'].forEach((item) => {
            res.template[item].items.forEach((item) => {
                // item.width = '140px';
            });
        });
        return res.template;
    }

    getTemplate = () => {
        const {
            props: {
                dispatch
            }
        } = this.comp;

        this.getMultiTemplate(this.reqData)
            .then((res) => {
                this.update({
                    context: res.context
                });
            });
    }

    getCurrentLanguage = () => {
        const {props} = this.comp;
        const {
            dispatch
        } = props;

        this.getLanguage('gx6008', 'hrtrn')
            .then((json, status, init) => {
                this.update({
                    language: json
                });
                this.updateStaffAreaMap({});
            });
    }
}  